<?php
error_reporting("E_ALL^E_NOTICE");
session_start();
?>
<html>
    <head>
        <meta name="key/words" content="berbagi,charity,community"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="css/bootstrap.css">
        <link rel="stylesheet" href="style.css">
        <link rel="stylesheet" href="css/datepickr.css">
        <title>Semua Berbagi - Indonesia Charity Community</title>
        <script type="text/javascript" src="js/autocomplete.js"></script>
        <script type="text/javascript" src="js/jquery.min.js"></script>
    </head>
    <body>
        <?php
        if (isset($_SESSION['user'])) {
            $status = $_SESSION['user']['status'];
        } else {
            include './masuk.php';
            exit();
        }
        if (isset($_SESSION['edit'])) {
            $foto = $_SESSION['edit']['foto'];
            $pass = $_SESSION['edit']['password'];
            $telp = $_SESSION['edit']['telepon'];
            $kab = $_SESSION['edit']['kabupaten'];
            $pinbb = $_SESSION['edit']['pinBB'];
            $namapengguna = $_SESSION['edit']['namapengguna'];
            $alamat = $_SESSION['edit']['alamat'];
            $tanggallahir = $_SESSION['edit']['tanggallahir'];
            $jeniskelamin = $_SESSION['edit']['jeniskelamin'];
            $sukses = $_SESSION['edit']['sukses'];
            echo '<script>alert("' . $foto . '\n'
            . $pass . '\n'
            . $telp . '\n'
            . $kab . '\n'
            . $pinbb . '\n'
            . $namapengguna . '\n'
            . $alamat . '\n'
            . $tanggallahir . '\n'
            . $jeniskelamin . '\n'
            . $sukses . '")</script>';
            unset($_SESSION['edit']);
        }
        include './function/Tampil.php';
        include './function/Pengguna.php';
        $pengguna = new Pengguna();
        $tampil = new Tampil();
        ?>
        <div class="container">
            <div class="navbar navbar-default" role="navigation">
                <div class="container-fluid">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed togle_margin" data-toggle="collapse" data-target=".navbar-collapse"> 
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span> 
                            <span class="icon-bar"></span> 
                            <span class="icon-bar"></span> 
                        </button> 
                        <form class="navbar-form" role="search">
                            <div class="input-group">
                                <input type="text" class="form-control" placeholder="Search" name="text_search">
                                <div class="input-group-btn">
                                    <button class="btn btn-default buttonCari" type="submit" name="button_search"><i class="glyphicon glyphicon-search"></i></button>
                                </div>
                            </div>
                        </form>
                    </div> 
                    <div class="navbar-collapse collapse"> 
                        <ul class="nav navbar-nav navbar-right"> 
                            <li>
                                <a href="pageUser.php">Beranda</a>
                            </li>
                            <li>
                                <a href="clearsession.php">Logout</a>
                            </li> 
                        </ul>                        
                        <div class="navbar-text navbar-right">Masuk sebagai <?php echo $status ?>     |</div>
                    </div> 
                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-body">
                    <form action="action_EditDataPengguna.php" method="POST" enctype="multipart/form-data">
                        <div class="row">
                            <div class="col-md-6 col-xs-12">
                                <img src="img/logo.png" class="img-responsive im"/>
                                </br>
                                </br>
                                <?php
                                if ($pengguna->tampilFoto($status) == '') {
                                    ?>
                                    <img src="foto/noimage.png" class="img-circle img-thumbnail" width="150" height="150"/>
                                    </br>
                                    <label>Upload Foto :</label><input type="file" name="uploadFile"/>
                                    <?php
                                } else {
                                    ?>
                                    <img src="<?php echo $pengguna->tampilFoto($status) ?>" class="img-circle img-thumbnail" width="150" height="150"/>
                                    </br>
                                    <label>Upload Foto :</label><input type="file" name="uploadFile"/>
                                <?php }
                                ?>
                                </br>
                                <?php
                                if ($pengguna->tampilNamaPengguna($status) == '') {
                                    ?>
                                    <label>Nama : </label><input type="text" class="form-control" name="namapengguna"/>
                                    </br>
                                    <?php
                                } else {
                                    ?>
                                    <label>Nama : </label><input type="text" class="form-control" value="<?php echo $pengguna->tampilNamaPengguna($status) ?>" name="namapengguna"/>
                                    </br>
                                    <?php
                                }
                                if ($pengguna->tampilPassword($status) == '') {
                                    ?>
                                    <label>Password : </label><input type="password" class="form-control" name="password"/>
                                    </br>
                                    <?php
                                } else {
                                    ?>
                                    <label>Password : </label><input type="password" class="form-control" value="<?php echo $pengguna->tampilPassword($status) ?>" name="password"/>
                                    </br>
                                    <?php
                                }
                                ?>
                            </div>
                            <div class="col-md-6 col-xs-12">
                                <?php
                                if ($pengguna->tampiltelpPengguna($status) == '') {
                                    ?>
                                    <label>Telepon : </label><input type = "text" class="form-control" name="telepon"/>
                                    </br>
                                    <?php
                                } else {
                                    ?>
                                    <label>Telepon : </label><input type = "text" class="form-control" value = "<?php echo $pengguna->tampiltelpPengguna($status) ?>" name = "telepon"/>
                                    </br>
                                    <?php
                                }
                                if ($pengguna->tampilPinBB($status) == '') {
                                    ?>
                                    <label>Pin BB : </label><input type = "text" class="form-control" name="pinBB"/>
                                    </br>
                                    <?php
                                } else {
                                    ?>
                                    <label>Pin BB : </label><input type = "text" class="form-control" value = "<?php echo $pengguna->tampilPinBB($status) ?>" name = "pinBB"/>
                                    </br>
                                    <?php
                                }
                                if ($pengguna->tampilAlamatPengguna($status) == '') {
                                    ?>
                                    <label>Alamat : </label><input type = "text" class="form-control" name="alamat"/>
                                    </br>
                                    <?php
                                } else {
                                    ?>
                                    <label>Alamat : </label><input type = "text" class="form-control" value = "<?php echo $pengguna->tampilAlamatPengguna($status) ?>" name = "alamat"/>
                                    </br>
                                    <?php
                                }
                                if ($pengguna->tampilTglLahir($status) == '') {
                                    ?>
                                    <label>Tanggal Lahir : </label>
                                    <input type='text' class="form-control" name="tanggallahir" id='datepicker'/>
                                    <?php
                                } else {
                                    ?>
                                    <label>Tanggal Lahir : </label>
                                    <input type='text' class="form-control" name="tanggallahir" id='datepicker' value = "<?php echo $pengguna->tampilTglLahir($status) ?>"/>
                                    <?php
                                }
                                ?>
                                <script type="text/javascript" src="js/datepickr.min.js"></script>
                                <script type="text/javascript">
                                    new datepickr('datepicker', {
                                        'dateFormat': 'd/m/y'
                                    });
                                </script>
                                <label>
                                    Jenis Kelamin :
                                </label>
                                <?php
                                if ($pengguna->tampilJenisKelamin($status) == 'l') {
                                    ?>
                                    <div class="radio">
                                        <label>
                                            <input type="radio" name="jeniskelamin" id="jeniskelaminRadiolaki" value="lakilaki" checked>
                                            Laki-Laki
                                        </label>
                                    </div>
                                    <div class="radio">
                                        <label>
                                            <input type="radio" name="jeniskelamin" id="jeniskelaminRadioperempuan" value="perempuan">
                                            Perempuan
                                        </label>
                                    </div>
                                    <?php
                                } else if ($pengguna->tampilJenisKelamin($status) == 'p') {
                                    ?>
                                    <div class="radio">
                                        <label>
                                            <input type="radio" name="jeniskelamin" id="jeniskelaminRadiolaki" value="l">
                                            Laki-Laki
                                        </label>
                                    </div>
                                    <div class="radio">
                                        <label>
                                            <input type="radio" name="jeniskelamin" id="jeniskelaminRadioperempuan" value="p" checked>
                                            Perempuan
                                        </label>
                                    </div>
                                    <?php
                                } else {
                                    ?>
                                    <div class="radio">
                                        <label>
                                            <input type="radio" name="jeniskelamin" id="jeniskelaminRadiolaki" value="lakilaki">
                                            Laki-Laki
                                        </label>
                                    </div>
                                    <div class="radio">
                                        <label>
                                            <input type="radio" name="jeniskelamin" id="jeniskelaminRadioperempuan" value="perempuan">
                                            Perempuan
                                        </label>
                                    </div>
                                    <?php
                                }
                                if ($pengguna->cekKabupatenPengguna($status) == 'belum') {
                                    ?>
                                    <label>Kabupaten : </label>
                                    <input type="text" class="form-control" name="kabupaten" id="kab" onkeyup="autocomplet()"/>
                                    <ul id="kab_list" class="list-unstyled kab_list"></ul>
                                    </br>
                                    <?php
                                } else {
                                    ?>
                                    <label>Kabupaten : </label>
                                    <input type="text" class="form-control" value="<?php echo $pengguna->tampilKabupatenPengguna($status) ?>" name="kabupaten" id="kab" onkeyup="autocomplet()"/>
                                    <ul id="kab_list" class="list-unstyled kab_list"></ul>
                                    </br>
                                    <?php
                                }
                                ?>
                                </br>
                                <input type="submit" class="btn btn-primary" value="SIMPAN" name="simpanData"/>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

            <div class="panel panel-default panelKat">
                <div class="panel-footer panelKaki">
                    <div class="row">
                        <div class="col-md-12 col-xs-12">
                            <br><br><br>
                            <center><label class="fontKaki"><h4>@ Copyright 2014 semua berbagi - All right reserved</h4></label></center>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>